<template>
  <div data-v-617ee70e="" class="special-container">
  <div data-v-617ee70e="" role="feed" class="special-list_van-list">

    <!-- 下拉刷新 -->
    <van-pull-refresh v-model="loading" success-text="刷新成功" @refresh="onRefresh">
      <van-list v-model="loading" :finished="finished" :offset="offset" finished-text="没有更多了" @load="onLoad">
        <div data-v-617ee70e="" class="van-cell" v-for="item in data" :key="item.id">
          <div data-v-617ee70e="" class="van-cell__value van-cell__value--alone">
            <div data-v-617ee70e="" class="van-image">
              <img :src="item.scene_pic_url" class="van-image__img" style="object-fit: cover;">
            </div>
            <div data-v-617ee70e="" class="tmain">
              <h2 data-v-617ee70e="" class="tit van-ellipsis">{{ item.title }}</h2>
              <p data-v-617ee70e="" class="summary">{{ item.subtitle }}</p><span data-v-617ee70e=""
                class="price">￥{{ item.price_info }}元</span>
            </div>
          </div>
        </div>
        
      </van-list>
    </van-pull-refresh>
  </div>
  </div>
</template>

<script>
import { GetSpecial } from "@/api";

export default {
  // async mounted() {
  //   this.init();
  // },
  data() {
    return {
      search_value: "",
      page: 0,
      size: 10,
      count: 0,
      totalPages: 0,
      pageSize: 0,
      currentPage: 0,
      data: [],
      offset: "30",
      loading: false,
      finished: false,
      refreshing: false,
    }
  },
  methods: {
    async init() {
      const {
        data: {
          data: { count, totalPages, pageSize, currentPage, data },
        },
      } = await GetSpecial(this.page, this.size);
      console.log(count);
      console.log(totalPages);
      console.log(pageSize);
      console.log(currentPage);
      console.log(data);
      this.count = count;
      this.totalPages = totalPages;
      this.pageSize = pageSize;
      this.currentPage = currentPage;
      //this.data = data;
      this.data = this.data.concat(data)
      //加载完成
      this.loading = false
      //如果data长度为0，则加载完成
      if (data.length === 0) {
        this.finished = true
        console.log("加载完成")
      } else {
        this.finished = false
      }
    },
    onLoad() {
      if (this.loading) {
        //当触发上拉时isLoading为false,当前页加一
        this.page = this.page + 1
      } else {
        //当下拉刷新时isLoading为true;将列表置空，重新从第一页查询，加载完成
        this.data = []
        this.page = 1
        this.loading = false
      }
      //调用列表接口把下一页获取到的date通过concat更新到一个新数组中并赋值给tableList 
      this.init()
    },
    onRefresh() {
      //数据开始加载
      this.finished = false
      //异步操作并更新数据
      this.loading = true
      //调用onLoad()方法
      this.onLoad()
    }
  }
}
</script>

<style>
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
main,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
.special-container{
  padding-top: 1.44rem;
  padding-bottom: 47px;
}
.van-cell {
  padding: 0;
  border-bottom: 0.26667rem solid #ebedf0;
  position: relative;
  display: flex;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.special-list_van-list {
  padding: 0;
  border-bottom: 0.26667rem solid #ebedf0;
  position: relative;
  display: flex;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
  color: #323233;
  font-size: 0.37333rem;
  line-height: 0.64rem;
  background-color: #fff;
}

.van-cell__value van-cell__value--alone {
  color: #323233;
  text-align: left;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  word-wrap: break-word;
  flex: 1;
}

.van-image {
  display: block;
  width: 100%;
  height: 228.388px;
}

.van-image__img {
  display: block;
  width: 100%;
  height: 100%;
  color: #323233;
  text-align: left;
  word-wrap: break-word;
}

.tit van-ellipsis {
  font-size: 0.42667rem;
  color: #333;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.summary {
  color: #999;
  margin-top: 0.05333rem;
}

.price {
  color: #8b0000;
  margin-top: 0.4rem;
  display: block;
}

.tmain {
  padding: 0.5rem 0.6667rem;
}
.van-list__finished-text{
  color: #969799;
  font-size: 1rem;
  line-height: 1.33333rem;
  text-align: center;
}
.van-list__placeholder {
  height: 0;
  pointer-events: none;
}
</style>